import dayjs from "dayjs"

const transactionTypes = [
    "Maya Deposit",
    "Maya Withdraw",
    "Withdraw Failed",
    "Bank Transfer",
    "Bonus Received",
]

const actionTypes = [
    "recharge",
    "withdraw",
    "cancel_withdraw",
    "bet",
    "change_bet",
    "settle",
    "bonus",
    "commission",
    "adjust",
] as const

const statusTypes = ["PENDING", "COMPLETED", "CANCELED", "TIMEOUT"] as const

export const record = () => {
    return Array.from({ length: 10 }, (_, index) => {
        const amount =
            Math.random() < 0.5
                ? Math.floor(Math.random() * 10000 + 2000)
                : -Math.floor(Math.random() * 10000 + 500)

        const date = new Date(
            2024,
            5,
            Math.floor(Math.random() * 30) + 1,
            Math.floor(Math.random() * 24), // 随机小时 0-23
            Math.floor(Math.random() * 60), // 随机分钟 0-59
            Math.floor(Math.random() * 60), // 随机秒数 0-59
        )
        const formattedDate = dayjs(date).format("YYYY/MM/DD HH:mm:ss")

        return {
            id: `${new Date().getTime()}${Math.random().toString(36).substring(2, 15)}`,
            type: transactionTypes[Math.floor(Math.random() * transactionTypes.length)],
            channelName: transactionTypes[Math.floor(Math.random() * transactionTypes.length)],
            amount: amount + "",
            date: formattedDate,
            balance: 2000 + amount + "",
            before_balance: 2000 + amount + "",
            status: statusTypes[Math.floor(Math.random() * statusTypes.length)],
            action: actionTypes[Math.floor(Math.random() * actionTypes.length)],
            timestamp: date.getTime(),
        }
    }).sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()) as {
        id: string
        type: string
        channelName: string
        amount: string
        date: string
        balance: string
        before_balance: string
    }[]
}
